<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Schools Management System</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../style.css" media="screen" />

</head>
<body>
<?php
require_once '../Login/databaseconnection.php';
if(!loggedin())
{
require_once '../index.php';
}
   
   else
   {
 if(isset($_POST['Search']))
	   {
	  $Lab_Id=$_POST['Lab_Id'];
   $School_Id=$_POST['School_Id'];
	  
	   if($Lab_Id=="Select One"||$School_Id=="Select One")
	   {
		   $_SESSION['errorin1']="Please select the Lab id and School id!";
	   
	   }
	   if($Lab_Id!="Select One"||$School_Id!="Select One")
	   {
	   	    $result=mysql_query("SELECT * FROM lab WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
if(mysql_num_rows($result)==0)
   {

	   $_SESSION['errornorow']="Very sorry there is no result,Please check your input and try again!";
   }
   }
	}  
	   
   ?>

<div id="wrap">

<div id="header">
<table width="1239" border="0">
  <tr>
    <td width="866" height="119" rowspan="2"><h1 class="heaaderte"><font color="#996699" style="text-shadow:#969" size="+6">Schools Management System</font></h1></td>
    <td width="110" height="88">&nbsp;</td>
    <td width="161">&nbsp;</td>
    <td width="84">&nbsp;</td>
  </tr>
  <tr>
    <td height="21">&nbsp;</td>
    <td>
	<?Php
	//$First_Name=$_SESSION['First_Name'];
    //$_SESSION['Last_Name']=$Last_Name;
	  if(isset($_SESSION['First_Name']))
	  
{
      echo "Hi,". $_SESSION['First_Name']." ".$_SESSION['Last_Name'];
}
?></td>
    <td><a href="../Logout.php" class="logout">Logout</a></td>
  </tr>
  </table>
</div>

<div id="menu1_bg">
		<div id="menu1">
			
	
			
		<ul>
				<li><a href="../index.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Home</font></a></li>
				<li><a href="../Schools/Schools.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Schools</font></a></li>
				<li><a href="../Teachers/teachers.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Teachers</font></a></li>
				<li><a href="Labs.php" class="active"><font color="#CCCC66" style="text-shadow:#969" size="+1">Labs</font></a></li>
				<li><a href="../Resources/Resources.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Resources</font></a></li>
                <li><a href="#"><font color="#CCCC66" style="text-shadow:#969" size="+1">Resource Team</font></a></li>
                         <li><a href="../Programmes/Programmes.php"><font color="#CCCC66" style="text-shadow:#969" size="+1">Programmes</font></a></li>
                                  <li><a href="../Competition/Competition.php""><font color="#CCCC66" style="text-shadow:#969" size="+1">Competitions</font></a></li>
                 <li></li>
			</ul>
	</div>
  </div>
<div class="left">
  
<div class="articles">
 <form action="#" method="POST">
 <table width="749" border="0">
      <tr>
        <td height="35" colspan="5" align="left" scope="row"><?php
		if(isset($_POST['Search']))
{
	if(isset($_SESSION['errorin1']))
	{
		echo $_SESSION['errorin1'];
		unset($_SESSION['errorin1']);
	}
	if(isset($_SESSION['errornorow']))
	{
		echo $_SESSION['errornorow'];
		unset($_SESSION['errornorow']);
	}
}
		?></td>
        <td colspan="2">&nbsp;</td>
        
        
      <tr>
        <td width="63" rowspan="2" align="left" scope="row">Search by</td>
      <td width="42" height="22" align="left" scope="row">Lab Id</td>
      <td width="8" align="left" scope="row">:-</td>
      <td colspan="2"><select name="Lab_Id" id="select">
	   <?php
	  
	  if(isset($_POST['Search']))
	  {
	echo '<option value="'.$Lab_Id.'">'.$Lab_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
        <?php
	  $lab=mysql_query("SELECT DISTINCT(Lab_Id) FROM lab");
	  
  while($row=mysql_fetch_array($lab))
  {
	 $Lab_Id=$row['Lab_Id'];

	  echo '<option value="'.$Lab_Id.'">'.$Lab_Id.'</option>';
  }
	  ?>
      </select></td>
      <td width="34" rowspan="2">Other Way:</td>
      <td width="362" rowspan="2"><input type="text" name="textfield" />
        <input name="SearchOther" align="middle" type="submit" value="Search" /></td>
      </tr>
    <tr>
      <td width="42" height="22" align="left" scope="row">School Id</th>
      <td width="8" align="left" scope="row">:-</td>
      <td colspan="2"><select name="School_Id" id="select">
	  <?php
	  
	  if(isset($_POST['Search']))
	  {
	echo '<option value="'.$School_Id.'">'.$School_Id.'</option>';
	  }
	  else
	  {
	  echo '<option value="Select One">Select One</option>';
	  }
	  ?>
        <?php
		
	  $lab=mysql_query("SELECT DISTINCT(School_Id) FROM lab");
	  
  while($row=mysql_fetch_array($lab))
  {
	  $Sch_Id=$row['School_Id'];

	  echo '<option value="'.$Sch_Id.'">'.$Sch_Id.'</option>';
  }
	  ?>
      </select></td>
      </tr>
    
    <tr>
      <td width="63" align="left" scope="row">&nbsp;</td>
      <th height="24" colspan="2" align="left" scope="row">&nbsp;</th>
      <th width="109" height="24" align="left" scope="row"></th>
      <th width="101" align="left" scope="row"><a href="SearchLabSch.php">Reset</a>|
        <input name="Search" align="middle" type="submit" value="Search" /></th>
      <th height="24" colspan="2" align="left" scope="row"></th>
      
    </tr>
  </table></form>
   <?php
   
	   if(isset($_POST['Search']))
	   {
	  
	$Lab_Id=$_POST['Lab_Id'];
   $School_Id=$_POST['School_Id'];
	   }
	   
	   if($Lab_Id!="Select One"&&$School_Id!="Select One")
	   {
     
   $result=mysql_query("SELECT * FROM lab WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");
	   $resultnet=mysql_query("SELECT * FROM network WHERE School_Id='$School_Id' AND Lab_Id='$Lab_Id'");

    echo '<table width="458" border="0">';
	while($row=mysql_fetch_array($result))
  { 
  if($rownet=mysql_fetch_array($resultnet))
{
	 $Availability_Of_LAN=$rownet['Availability_Of_LAN'];
   $LAN_Supplier=$rownet['LAN_Supplier'];
      	$Supplied_Date=$rownet['Supplied_Date'];
    $Speed_Of_WAN=$rownet['Speed_Of_WAN'];
    $WAN_Connection_Type=$rownet['WAN_Connection_Type'];
	$Wired_Date=$rownet['Wired_Date'];
	$Internet_Facilities=$rownet['Internet_Facilities'];
	}
  $Lab_Id=$row['Lab_Id'];
   $School_Id=$row['School_Id'];
 $Source_Of_Power=$row['Source_Of_Power'];
      	$Tp_Number=$row['Tp_Number'];
    $Account_Number=$row['Account_Number'];
    $Date_of_commencement=$row['Date_of_commencement'];   
       echo '<tr>';
        echo '<th width="200" height="25" scope="row">';
		echo "
		Source Of Power:";
		echo '</th>';
        echo '<td width="144">';
		echo "<input type='text' name='Source_Of_Power' value='$Source_Of_Power' readonly='readonly'/>";
		
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "
		Telephone Number:";
		echo '</th>';
        echo '<td>';
		echo "<input type='text' name='Source_Of_Power' value='$Tp_Number' readonly='readonly'/>";
		
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "
		Account Number:";
		echo '</th>';
        echo '<td>';
		echo "<input type='text' name='Source_Of_Power' value='$Account_Number' readonly='readonly'/>";
	
		echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Date of commencement :";
		echo '</th>';
       echo '<td>';
	   echo "<input type='text' name='Source_Of_Power' value='$Date_of_commencement' readonly='readonly'/>";

	   echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Availability of LAN:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Availability_Of_LAN))
		{
		echo "<input type='text' name='Availability_Of_LAN' value='$Availability_Of_LAN' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Availability_Of_LAN' readonly='readonly'/>";
		}
        echo '</td>';
      echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "LAN Supplier:"; 
		echo '</th>';
        echo '<td>';
		if(isset($LAN_Supplier))
		{
		echo "<input type='text' name='LAN_Supplier' value='$LAN_Supplier' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='LAN_Supplier' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	  echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Supplied Date:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Supplied_Date))
		{
		echo "<input type='text' name='Supplied_Date' value='$Supplied_Date' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Supplied_Date' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	 
 echo '</tr>';
      echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Speed Of WAN:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Speed_Of_WAN))
		{
		echo "<input type='text' name='Speed_Of_WAN' value='$Speed_Of_WAN' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Speed_Of_WAN' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	  echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "WAN Connection Type:"; 
		echo '</th>';
        echo '<td>';
		if(isset($WAN_Connection_Type))
		{
		echo "<input type='text' name='WAN_Connection_Type' value='$WAN_Connection_Type' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='WAN_Connection_Type' readonly='readonly'/>";
		}
		
		echo '</td>';
      echo '</tr>';
	  
	  echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Wired Date:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Wired_Date))
		{
		echo "<input type='text' name='Wired_Date' value='$Wired_Date' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Wired_Date' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	   echo '<tr>';
        echo '<th height="25" scope="row">';
		echo "Internet_Facilities:"; 
		echo '</th>';
        echo '<td>';
		if(isset($Internet_Facilities))
		{
		echo "<input type='text' name='Internet_Facilities' value='$Internet_Facilities' readonly='readonly'/>";
		}
		else
		{
		echo "<input type='text' name='Internet_Facilities' readonly='readonly'/>";
		}
		echo '</td>';
      echo '</tr>';
	 
  }
    echo '</table>';
	}
	
   ?>
 
</div>
</div>

<div class="rightmenu"> 
<h1>LABS</h1><br />
<table width="220" border="0">
  <tr>
    <td width="210" height="41"><a href="RegLab.php">Add New Lab</a></td>
   

  </tr>
  <tr>
    <td height="41"><a href="SearchLab.php">Search a Lab</a></td>
    
    
  </tr>
  <tr>
    <td height="41"><a href="SearchLabSch.php">Search Labs for a school</a></td>

    
  </tr>
  <tr>
    <td height="41"><a href="UpdateLab.php">Update a  Lab of a School</a></td>
 
    
  </tr>
  <tr>
    <td height="41"><a href="DelLab.php">Delete a  Lab of a School</a></td>
    
    
  </tr>
  <tr>
    <td height="41"><a href="viewall.php">View All</a></td>
   

  </tr>
</table>
</div>
 
 <div style="clear: both;"> </div>


<div id="footer">
  <table width="1236" height="38" border="0">
    <tr>
      <td width="904" height="34">Schools Managemrnt System &copy; 2012 </td>
      <td width="50"><strong><a href="#" class="active">Home</a><a href="#"></a></strong>|</td>
      <td width="80"><strong><a href="#">Contact us</a></strong>|</td>
      <td width="40"><a href="http//www.facebook.com"><img src="../images/facebook1.png" width="38" height="38"/></a></td>
      <td width="38"><a href="http//twitter.com"><img src="../Images/twitter.png" width="38" height="38"/></a></td>
      <td width="36"><a href="http//www.google.lk"><img src="../Images/google.png" width="38" height="38"/></a><a href=""http="http"//www.yahoo.com""></a></td>
      <td width="58"><a href=""http="http"//www.yahoo.com""><img src="../Images/yahoo.png" alt="" width="38" height="38"/></a></td>
    </tr>
  </table>
</div>
</div>
<?php
}
	  
	   ?>
</body>
</html>